/*
 * GuudListener.cpp
 *
 *  Created on: 2013-1-23
 *      Author: heqiu
 */

#include "GuudListener.h"

namespace guud {

GuudListener::GuudListener() {
	m_uiMSec = 100;
	m_bQuit = false;
	m_iMouseX = 0;
	m_iMouseY = 0;
}
GuudListener::~GuudListener() {

}
void GuudListener::setDelay(uint32_t uiMSec) {
	m_uiMSec = uiMSec;
}

void GuudListener::beginListen() {
	m_bQuit = false;
	while (m_bQuit == false) {
		SDL_Event stEvent;
		while (SDL_PollEvent(&stEvent)) {
			m_iMouseX = stEvent.motion.x;
			m_iMouseY = stEvent.motion.y;
			handleEvents(stEvent);
			if (stEvent.type == SDL_QUIT) {
				//m_bQuit = true;
				gameQuit();
			}
		}
		SDL_Delay(m_uiMSec);
	}
}

void GuudListener::handleEvents(GuudEvent &stEvent) {

}
void GuudListener::gameQuit() {
	m_bQuit = true;
}

}
